import cPickle

class Package():
    
    def __init__(self,command):
        self.command = command
        #self.valid = True
        self.keys = {}
        
    def add(self,key,value):
        self.keys[key] = value
        
    def get(self,key):
        try: value = self.keys[key]
        except KeyError:
            value = ""
        return value
    
    def fromStr(self,data):
        return cPickle.loads(str(data))
    
    fromStr = classmethod(fromStr)
    
    def toStr(self):
        return cPickle.dumps(self)